# -*- coding: UTF-8 -*-
from typing import List

from leetcode_helper import TestcaseHelper, SolutionBase


class Solution(SolutionBase):
    # 解题的方法，命名和Leetcode的保持一致即可
    def minCostClimbingStairs(self, cost: List[int]) -> int:
        dp = [cost[0], cost[1]]  # dp[i]表示爬上第i个阶梯所花费的最小体力值
        cost_count = len(cost)

        for i in range(2, cost_count):
            dp.append(min(dp[i - 1], dp[i - 2]) + cost[i])

        # 最后如果是一步就到达顶层，则可以不计算最后一步的cost
        return min(dp[cost_count - 1], dp[cost_count - 2])


if __name__ == '__main__':
    solution = Solution()

    # 按照leetcode的题目说明，将基本的test case填入
    # 每条case的最后一个元素是正确的结果，即期待的结果
    # 使用元组来保存输入的数据，期待的结果
    testcases = [
        ([10, 15, 20], 15),
        ([1, 100, 1, 1, 1, 100, 1, 1, 100, 1], 6)
    ]

    for case_item in testcases:
        # 获取测试用的case和期待的执行结果
        input1 = case_item[0]
        expect = case_item[len(case_item) - 1]

        exec_result = solution.minCostClimbingStairs(input1)

        # 判断执行结果，输出提示信息
        check_result = solution.check_result(expect, exec_result)
        TestcaseHelper.print_case(check_result, case_item, exec_result)
